package com.leyou.service.impl;

import com.leyou.configurations.AppConstants;
import com.leyou.service.FileUploadService;
import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Service;

import java.io.File;

@Service
public class FileUploadServiceImpl implements FileUploadService {

    @Override
    public String uploadFile(String fileName, byte[] data) throws Exception {
//        String dst = AppConstants.imgPath + fileName;
        String dst = "C:/other/tmp/img/" + fileName;
        FileUtils.writeByteArrayToFile(new File(dst), data);
        String url = "http://image.leyou.com/img/" + fileName;
        return url;
    }
}
